#include "bsp_g3507std.h"
#include "ti_msp_dl_config.h"
#include "user_main.h"


uint32_t g_g3507_board_order_array[G3507_BOARD_ORDER_ARRAY_LEN] = { 0 };
uint32_t g_g3507_board_sensor_array[G3507_BOARD_SENSOR_ARRAY_LEN] = { 0 };

////////////////////////////////////
////////////////////////////////////
//ADC
uint32_t gADCSamples[ADC_SAMPLE_SIZE];
uint32_t gADCSamples_0[ADC_SAMPLE_SIZE];

void adc_0_dma_config(uint32_t *destaddr, uint16_t size)
{
    DL_DMA_enableChannel(DMA, DMA_CH0_CHAN_ID);
    DL_DMA_setSrcAddr(DMA, DMA_CH0_CHAN_ID,(uint32_t) &(ADC0->ULLMEM.MEMRES[0]));
    DL_DMA_setDestAddr(DMA, DMA_CH0_CHAN_ID, (uint32_t) destaddr);
    DL_DMA_setTransferSize(DMA, DMA_CH0_CHAN_ID, size);
    DL_DMA_enableChannel(DMA, DMA_CH0_CHAN_ID);
}

void adc_1_dma_config(uint32_t *destaddr, uint16_t size)
{
    DL_DMA_enableChannel(DMA, DMA_CH1_CHAN_ID);
    DL_DMA_setSrcAddr(DMA, DMA_CH1_CHAN_ID,(uint32_t) &(ADC1->ULLMEM.MEMRES[0]));
    DL_DMA_setDestAddr(DMA, DMA_CH1_CHAN_ID, (uint32_t) destaddr);
    DL_DMA_setTransferSize(DMA, DMA_CH1_CHAN_ID, size);
    DL_DMA_enableChannel(DMA, DMA_CH1_CHAN_ID);
}

int g3507_board_get_sensor( uint32_t *board_sensor_array , uint32_t board_sensor_array_len  )
{
    g_g3507_board_sensor_array[0] = gADCSamples[0];
    g_g3507_board_sensor_array[1] = gADCSamples[1];
    g_g3507_board_sensor_array[2] = gADCSamples_0[0];
    g_g3507_board_sensor_array[3] = gADCSamples_0[1];
    return 0;
}

int g3507_board_set_order( uint32_t *board_order_array  , uint32_t board_order_array_len  )
{

    return 0;
}
